#ifndef __ATL_KSTDIO_H__
#define __ATL_KSTDIO_H__
#include <cstdint.h>
#include "fs.h"
#include <linked_list.h>

#include "errno.h"
#include "fcntl.h"

#include "process.h"

#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2

typedef int KFILE;
#ifndef FILETABLE_DEF
#define FILETABLE_DEF
typedef struct filetable {
	LLIST * freed_fds;
	int		fd_alloc;
	ILLIST *fd_table;
} filetable_t;
#endif

typedef struct fileinfo {
	struct vfs_node *node;
	uint32_t pos;
	uint32_t oflags;
	uint32_t refs;
} fileinfo_t;

void create_fd(KFILE fd,uint32_t flags,uint32_t inode,read_fs_t read_hook,write_fs_t write_hook);

int link_fd(process_info_t *source,process_info_t *dest,KFILE source_fd,KFILE dest_fd);

typedef struct process_info process_info_t;

void initialize_filetable(process_info_t *p);

KFILE getfreefd();
int kmount(char* mp,char* dev,char *type);
int kumount(char *mp,char *type);
int		 read (KFILE fd,uint8_t *buffer,uint32_t length);
int		 write(KFILE fd,uint8_t *buffer,uint32_t length);
int		 seek (KFILE fd,uint32_t position, uint8_t whence);
KFILE	 open (char *name,uint32_t mode,uint32_t flags);
int		 close(KFILE fd);
int 	 chdir (char *name);
int		 mkdir (char *name);
KFILE create_loop(int bufsize);
KFILE *create_pipe(int bufsize);
int pipe_available(KFILE fd);
int		 lenf(KFILE fd);
#endif